﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="UserEdited.cs" company="DissingNellemann">
//   
// All rights reserved </copyright>
// <summary>
//   The user edited.
// </summary>
// --------------------------------------------------------------------------------------------------------------------
namespace Website.Models.ViewModels
{
    using System.ComponentModel.DataAnnotations;
    using System.Web.Mvc;

    using DataAnnotationsExtensions;

    using Website.CRUDServices;
    using Website.Models.Base;

    /// <summary>
    ///     The user edited.
    /// </summary>
    public class UserEdited : Entity
    {
        #region Public Properties

        /// <summary>
        ///     Gets or sets the email.
        /// </summary>
        [Required(ErrorMessage = "Du skal angive en E-mail adresse.")]
        [Email(ErrorMessage = "Email addressen er ugyldig.")]
        public string Email { get; set; }

        /// <summary>
        ///     Gets or sets the name.
        /// </summary>
        [Required(ErrorMessage = "Du skal angive et brugernavn.")]
        public string Name { get; set; }

        /// <summary>
        ///     Gets or sets the password.
        /// </summary>
        [DataType(DataType.Password)]
        public string Password { get; set; }

        /// <summary>
        ///     Gets or sets the password 2.
        /// </summary>
        [DataType(DataType.Password)]
        [Compare("Password", ErrorMessage = "De to kodeord skal være ens.")]
        public string Password2 { get; set; }

        /// <summary>
        ///     Gets or sets the phone number.
        /// </summary>
        [Required(ErrorMessage = "Du skal angive et telefon nummer.")]
        [StringLength(8, ErrorMessage = "Telefon nummeret skal være på mindst 8 tegn.")]
        public string PhoneNumber { get; set; }

        /// <summary>
        ///     Gets or sets the username.
        /// </summary>
        [Required(ErrorMessage = "Du skal angive et brugerens navn.")]
        public string Username { get; set; }

        #endregion

        #region Public Methods and Operators

        /// <summary>
        /// The convert.
        /// </summary>
        /// <param name="dto">
        /// The dto.
        /// </param>
        /// <returns>
        /// The <see cref="UserEdited"/>.
        /// </returns>
        public static UserEdited Convert(User dto)
        {
            return new UserEdited
                       {
                           Email = dto.Email, 
                           ID = dto.ID, 
                           Name = dto.Name, 
                           PhoneNumber = dto.PhoneNumber, 
                           Username = dto.Username, 
                       };
        }

        #endregion
    }
}